// 发送请求获取用户信息

getUserInfo()
function getUserInfo() {
    axios.get('/my/userinfo',{
        headers:{
            Authorization:localStorage.getItem('token'),
    
        },
    })
    .then(({data:{data,status,message}})=>{
        console.log(data);
        // if (status===1&&message==="身份认证失败！") {
        //     location.href='/login.html'
        // }
      let name = data.nickname || data.username
      $('#welcome').html(`~欢迎${name}~`).show()
        if (data.user_pic) {
            $('.avatar').attr('src',data.user_pic).show()
            $('.text-avatar-box').hide()
        }else{
            $('.text-avatar-box').show()
            $('.text-avatar').text(name[0].toUpperCase())
            $('.avatar').hide()
         
        }
    })
}

// 退出页面

const layer = layui.layer
$('#btnLogout').on('click',function(){
    layer.confirm(`确定要退出吗?`, {icon: 3, title:'提示'}, function(index){
        //do something
        
        layer.close(index);
        localStorage.removeItem('token')
        location.href='./login.html'
      });
})
